package com.lvyq.myplayer.widget

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.ImageView
import android.widget.RelativeLayout
import android.widget.TextView
import com.lvyq.myplayer.R
import com.lvyq.myplayer.model.area.MvPagerBeans
import com.squareup.picasso.Picasso
import jp.wasabeef.picasso.transformations.CropCircleTransformation
import jp.wasabeef.picasso.transformations.RoundedCornersTransformation
import org.jetbrains.anko.find

/**
 * 文件描述：MvItemView
 * 作者：lvyq
 * 创建时间：2025-02-26
 * 修改时间：2025-02-26
 */
class MvItemView:RelativeLayout {

    var singer:TextView
    var song:TextView
    var timer:TextView
    var bg:ImageView
    var singerImg :ImageView
    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )

    init {

        View.inflate(context, R.layout.item_video,this)
        singer=  find<TextView>(R.id.singer)
        song=findViewById(R.id.song)
        singerImg= find<ImageView>(R.id.singerImg)
        bg=find<ImageView>(R.id.bg)
        timer=find<TextView>(R.id.timer)

    }

    /**
     * 适配每个条目view
     */
    fun setData(data: MvPagerBeans) {
        //歌手名称
        singer.setText(data.singer)
        //歌曲名称
        song.setText(data.title)
        //时长
        timer.setText(data.timer)
        //缩略图
        Picasso.with(context).load(data.img).transform(RoundedCornersTransformation(70,0)).into(bg)
        //歌手头像
        Picasso.with(context).load(data.singerImg).transform(CropCircleTransformation()).into(singerImg)



    }

}